#include<iostream>
#include<vector>

using namespace std;

int jump(vector<int>& nums) {
    int cnt = 0, n = nums.size(), end = 0, maxp = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (i <= maxp)
        {
            maxp = max(maxp, nums[i] + i);
            if (i == end)
            {
                end = maxp;
                cnt++;
            }
        }
    }
    return cnt;
}

vector<int> partitionLabels(string s) {
    vector<int> last(26);
    vector<int> res;
    for (int i = 0; i < s.size(); i++)
        last[s[i] - 'a'] = i;
    int st = 0, end = 0;
    for (int i = 0; i < s.size(); i++)
    {
        end = max(end, last[s[i] - 'a']);
        if (i == end)
        {
            res.push_back(end - st + 1);
            st = end + 1, end = i + 1;
        }
    }
    return res;
}